<?php


/**
 * The WordPress menu builder
 *
 * This function builds the menus for us
 * @return	null
 */
function wps3_menus()
{
	add_media_page('WPS3Slider','WPS3Slider','manage_options','wps3slider','wps3_main_menu');
}
				

/**
 * The main menu
 *
 * @return null
 */
function wps3_main_menu()
{
	?>
    <div class="wrap">
    	<div id="icon-themes" class="icon32"></div>
        <h2>WPS3Slider</h2>
        <!-- JUI Tabs -->
        <div id="wps3-tabs">
        	
            <ul>
              <li><a href="#wps3-tab-1">Galleries</a></li>
              <li><a href="#wps3-tab-2">Documentation</a></li>
            </ul>
            
            <!-- WPS3 Galleries -->
            <div id="wps3-tab-1">
            <?php require_once(dirname(__FILE__).'/wps3gal.php'); ?>
            </div>
            <!-- END GALLERIES -->
            
            <!-- WPS3 Documentation -->
            <div id="wps3-tab-2">
            <?php require_once(dirname(__FILE__).'/wps3doc.php'); ?>
            </div>
            <!-- END Documentation -->
            
        </div>
        <!-- end JUI Tabs -->
        
    </div>
    <?php
}
add_action('admin_menu','wps3_menus');


/**
 * Admin head
 *
 * load the requried files for the admin screens
 * to work. 
 *
 */
function wps3_admin_head()
{
	wp_register_style('jui-style', WP_PLUGIN_URL . '/wps3slider/assets/jquery-ui-1.7.3.custom.css');
	wp_register_style('wps3-admin', WP_PLUGIN_URL . '/wps3slider/assets/admin.css');
	wp_print_styles('jui-style');
	wp_print_styles('wps3-admin');
	wp_print_scripts('jquery');
	wp_print_scripts('thickbox');
	wp_print_scripts('jquery-ui-core');
	wp_print_scripts('jquery-ui-tabs');

}
add_action('admin_head','wps3_admin_head');


/**
 * Admin footer
 */
function wps3_admin_footer()
{
	?>
    <script type="text/javascript">
	//<![CDATA[
	jQuery(document).ready(function($) {
		$('#wps3-tabs').tabs();
		<?php if(isset($_GET['gid'])) : ?>
		$('tr#wps3-gallery-<?php echo (int)$_GET['gid']; ?>').addClass('selected');
		<?php endif; ?>
	});
	//]]>
	</script>
    <?php
}
add_action('admin_footer','wps3_admin_footer');
?>